import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Solution {
    public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) {
        dfs(A, B, C, A.size());
    }

    private void dfs(List<Integer> a, List<Integer> b, List<Integer> c, int n) {
        if (n == 1) {
            c.add(a.remove(a.size() - 1));
            return;
        }
        dfs(a, c, b, n - 1);
        c.add(a.remove(a.size() - 1));
        dfs(b, a, c, n - 1);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            List<Integer> A = new LinkedList<>();
            List<Integer> B = new LinkedList<>();
            List<Integer> C = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                A.add(i);
            }
            Solution solution = new Solution();
            solution.hanota(A, B, C);
            System.out.println(C);
        }
    }
}